﻿
function projTransformToWGS84(coordinate){
	 //var wgs84 = ol.coordinate.toStringHDMS(ol.proj.transform(
    //        coordinate, 'EPSG:3857', 'EPSG:4326'));
    
    
    var wgs84 = ol.proj.transform(coordinate, 'EPSG:3857', 'EPSG:4326');
    
    
    var string84 = wgs84[0] + "," +wgs84[1];

    
     //var firstStr = data.substring(1,data.length-1);
	 	var tempArr = [];
	 	tempArr = string84.split(",");
	 	var resArr = [];
	 	for (var i = 0; i< tempArr.length; i++) {
		 	resArr.push(Number(tempArr[i]));
		 }
    alert(wgs84[0] + ";" +wgs84[1]);
    
    return wgs84;
}


function popupInfo( coordinate, content){
	
	var popup = map.getOverlayById("popup123");
	var element_over = popup.getElement();
	//alert("jinlail");
	if(coordinate)
	{		
		
		 $(element_over).popover('destroy');
		popup.setPosition(coordinate);	
		
		$(element_over).popover({
			'placement' : 'top',
			'animation': false,
			'html' : false,
			'content' : content
		});
		$(element_over).popover('show');
		
	}
	else{
		$(element_over).popover('destroy');
	}
	
}


function highNodes(layer, coordinates){
	
	
	if(!layer){
		return;
	}
	///先清除layer元素
	layer.getSource().clear();
	if(coordinates)
	{
		for(var i =0; i< coordinates.length; i++){
		
			addFeature(layer, i, coordinates[i], "Point", null);
		}
		
		addFeature(layer, i, coordinates, "Line", null);
		
	}
}


//屏幕截图下载
function downloadImage(id) {
    html2canvas($("#" + id + " .ol-unselectable")[0], {
        allowTaint: true,
        taintTest: false,
        onrendered: function(canvas) {
            //生成base64图片数据
            var dataUrl = canvas.toDataURL();
            var a = $("<a></a>").attr("href", dataUrl).attr("download", "img.png").appendTo("body");
            a[0].click();
            a.remove();
        }
    });
}